
//
//  BoardButton.m
//  HXDemo
//
//  Created by 李亚军 on 16/11/25.
//  Copyright © 2016年 李亚军. All rights reserved.
//

#import "BoardButton.h"

IB_DESIGNABLE
@implementation BoardButton
- (void)awakeFromNib {
    [super awakeFromNib];
    [self initDefaultAttributes];
}


- (void)drawRect:(CGRect)rect {
    
    [self initDefaultAttributes];
    
    self.layer.borderColor = self.boardLineColor.CGColor;
    self.layer.borderWidth = self.boardWidth;
    self.layer.cornerRadius = self.cornerRadius;
    self.layer.masksToBounds = YES;
}
/// 初始化默认属性
- (void)initDefaultAttributes {
    
    if (self.boardLineColor == nil) {
        self.boardLineColor = [UIColor whiteColor];
    }
}

#pragma mark - 重写 setter 方法
- (void)setBoardWidth:(CGFloat)boardWidth {
    _boardWidth = boardWidth;
    [self setNeedsDisplay];
}

- (void)setCornerRadius:(CGFloat)cornerRadius {
    _cornerRadius = cornerRadius;
    [self setNeedsDisplay];
}

- (void)setBoardLineColor:(UIColor *)boardLineColor {
    
    _boardLineColor = boardLineColor;
    [self setNeedsDisplay];
}

- (void)setIsMaskTobounds:(BOOL)isMaskTobounds {
    _isMaskTobounds = isMaskTobounds;
    [self setNeedsDisplay];
}

@end
